package JAVA300.第十一章多线程;

/**
 * 3.InheritableThreadLocal
 */

public class thread_19_others_6ThreadLocal2 {


    private static ThreadLocal<Integer> threadLocal = new InheritableThreadLocal<>();



    public static void main(String[] args) {

        threadLocal.set(2);
        System.out.println(Thread.currentThread().getName()+"-->"+threadLocal.get());//main-->2

        //线程由main线程开辟
        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"-->"+threadLocal.get());//Thread-0-->null
        }).start();

    }


}
